package io;

import java.io.*;

public class FileWritertest {
    public static void main(String[] args) throws IOException {
        char[] chars = new char[1024];
        Reader fileReader=null;
        Writer writer=null;
        int count=0;
        try {
            writer=new FileWriter("d:/2.txt");
            fileReader = new FileReader("d:/1.txt");
            while ((count=fileReader.read(chars))!=-1){
                writer.write(chars,0,count);
                writer.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileReader.close();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
